<?php
class editAction extends rareAction{
    public function execute(){
        $id = $this->getGetParam('id',0);
        if($id == 0) forward('page/index');
        $pageDao = new DaoPage();
        $page = $pageDao->getOne("id = '$id'");
        $page['content'] = $page['content'];
        $this->assign('page',$page);
    }
    
	public function executePost(){
		$page = $this->getPostParam('page',array());
		$id = $this->getPostParam('id',0);
		if($id==0) jsonReturn(0,"edit fail!");
		if(empty($page)) jsonReturn(0,'edit fail!');
		$pageDao = new DaoPage();

		// get system date
		$now = date("Y-m-d H:i:s");
		$page['updateTime'] = $now;
		$re = $pageDao->update("id='$id'",$page);
		if($re){
			jsonReturn(1,'ok');
		}else{
			jsonReturn(0,'fail');
		}
	}
}
?>
